package org.example.sec05;

import com.google.protobuf.InvalidProtocolBufferException;
import com.seaway.models.sec05.v1.Television;
import com.seaway.models.sec05.v2.Type;
import org.example.sec05.parser.V1Parser;
import org.example.sec05.parser.V2Parser;
import org.example.sec05.parser.V3Parser;

public class Demo {

    public static void main(String[] args) throws InvalidProtocolBufferException {
      // v1();
      // v2();
       v3();
    }
    private static void v3() throws InvalidProtocolBufferException {
        var t = com.seaway.models.sec05.v3.Television.newBuilder()
                .setBrand("samesong").setType(com.seaway.models.sec05.v3.Type.HD).build();


        V1Parser.parse(t.toByteArray());
        V2Parser.parse(t.toByteArray());
        V3Parser.parse(t.toByteArray());

    }
    private static void v2() throws InvalidProtocolBufferException {
        var t = com.seaway.models.sec05.v2.Television.newBuilder()
                .setBrand("samesong")
                .setModel(2323)
                .setType(Type.HD)
                .build();
        V1Parser.parse(t.toByteArray());
        V2Parser.parse(t.toByteArray());
    }

    private static void v1() throws InvalidProtocolBufferException {
        var t = Television.newBuilder()
                .setBrand("samesong")
                .setYear(2323)
                .build();
        V1Parser.parse(t.toByteArray());
        V2Parser.parse(t.toByteArray());
    }
}
